package com.guomao.stream;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemoC {

    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();
        ArrayList<String> list2 = new ArrayList<>();

        Collections.addAll(list, "alice", "zuck", "bob", "cat", "donk", "elise", "five", "ghost", "hi", "hi");
        Collections.addAll(list2, "白眉鹰王", "灭绝师太");

        Stream<String> stream = list.stream();


        List<String> list1 = stream.toList();


        Object[] array = stream.toArray();

//        stream模型转换成成Collection集合
        List<String> list3 = stream.toList();
        for (String s : list3) {
            System.out.println(s);
        }

        stream.collect(Collectors.toSet());


        System.out.println(list1);


//        Stream<String> concat = Stream.concat(stream, list2.stream()).distinct().sorted();

//        concat.forEach((s)-> System.out.println(s));
//        concat.forEach(System.out::println);

//        Stream<Object> empty = Stream.empty();


//        stream.map(String::toUpperCase).forEach(System.out::println);

//        stream.filter(s -> s.length() > 4).limit(2).forEach(System.out::println);
//        stream.filter(s -> s.length() > 4).skip(2).forEach(System.out::println);

//        stream.filter(s-> s.contains("o")).forEach(System.out::println);
//        long size = stream.filter(s -> s.contains("o")).count();
//        System.out.println(size);
//        stream.filter(s -> s.contains("o")).forEach(System.out::println);
        //size -> long
        //forEach -> void

    }
}
